package ru.classbase.dbdumper

import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import java.time.format.DateTimeFormatter
import java.time.format.DateTimeFormatter.*


@Configuration
class Config {

    @Bean
    fun dateTimeFormatter(props: AppProperties): DateTimeFormatter {
        return if (props.dateTimeFormat == null) ISO_LOCAL_DATE_TIME else ofPattern(props.dateTimeFormat)
    }

    @Bean
    fun dateFormatter(props: AppProperties): DateTimeFormatter {
        return if (props.dateFormat == null) ISO_LOCAL_DATE else ofPattern(props.dateFormat)
    }

}